<?php

require dirname(__FILE__) .'/libs/easyThumbnail.class.php';

function createThb($image, $destinationPath) {
	try {
		$thb = new easyThumbnail($image, $destinationPath);

		$thb->generate();

		$thbPath = $thb->getThumbnailName();

		return array(true, $thbPath);

	} catch (Exception $e) {
		$error = $e->getMessage();

		return array(false, $error);
	}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>Thumbnail exemple</title>
	</head>
	<body style="background:grey;">
		<div>
			<ul>
				<li>
<?php $test1 = createThb('images/test1.jpg', 'images/thb/'); ?>
					<p>Test 1 : jpeg image</p>
					<p>Original : <img src="images/test1.jpg" alt="" /></p>
<?php if (true === $test1[0]) : ?>
					<p>Thumbnail : <img src="<?php echo $test1[1]; ?>" alt="" /></p>
<?php else : ?>
					<p>Error : <?php echo $test1[1]; ?></p>
<?php endif ?>
				</li>
				<li>
<?php $test2 = createThb('images/test2.png', 'images/thb/'); ?>
					<p>Test 2 : png image</p>
					<p>Original : <img src="images/test2.png" alt="" /></p>
<?php if (true === $test2[0]) : ?>
					<p>Thumbnail : <img src="<?php echo $test2[1]; ?>" alt="" /></p>
<?php else : ?>
					<p>Error : <?php echo $test2[1]; ?></p>
<?php endif ?>
				</li>
				<li>
<?php $test3 = createThb('images/test3.png', 'images/thb/'); ?>
					<p>Test 3 : png image with transparency</p>
					<p>Original : <img src="images/test3.png" alt="" /></p>
<?php if (true === $test3[0]) : ?>
					<p>Thumbnail : <img src="<?php echo $test3[1]; ?>" alt="" /></p>
<?php else : ?>
					<p>Error : <?php echo $test3[1]; ?></p>
<?php endif ?>
				</li>
				<li>
<?php $test4 = createThb('images/test4.gif', 'images/thb/'); ?>
					<p>Test 4 : gif image</p>
					<p>Original : <img src="images/test4.gif" alt="" /></p>
<?php if (true === $test1[0]) : ?>
					<p>Thumbnail : <img src="<?php echo $test4[1]; ?>" alt="" /></p>
<?php else : ?>
					<p>Error : <?php echo $test4[1]; ?></p>
<?php endif ?>
				</li>
				<li>
<?php $test5 = createThb('images/test5.gif', 'images/thb/'); ?>
					<p>Test 5 : gif image with transparency</p>
					<p>Original : <img src="images/test5.gif" alt="" /></p>
<?php if (true === $test5[0]) : ?>
					<p>Thumbnail : <img src="<?php echo $test5[1]; ?>" alt="" /></p>
<?php else : ?>
					<p>Error : <?php echo $test5[1]; ?></p>
<?php endif ?>
				</li>
			</ul>
		</div>
	</body>
</html>
